#ifndef ODBC_DETAILS_STATEMENT_VISITOR_HPP
#define ODBC_DETAILS_STATEMENT_VISITOR_HPP

#include "odbc/details/os_sql_wrapper.hpp"

namespace odbc { namespace details
{

/// \internal
/// \brief
///		Just an utility class, providing a method for getting the statement handle from odbc::statement class.
/// \details
///		Inherit from this class, to get access to the handle.
///		\n
///		This class is friend of odbc::details class.
// TODO: Document
template< class Statement>
class statement_visitor
{
	// TODO: Statement concept check
protected:
	static SQLHSTMT get_statement_handle( Statement& stat)
	{
		return stat.handle_;
	}

	static void check_success( SQLRETURN ret_code, SQLHANDLE stat_h)
	{
		if( ret_code != SQL_SUCCESS && ret_code != SQL_SUCCESS_WITH_INFO)
		{
			throw odbc_error( ret_code, stat_h, SQL_HANDLE_STMT);
		}
	}

	static void check_success( SQLRETURN ret_code, const Statement& stat)
	{
		check_success( ret_code, get_statement_handle( stat));
	}
};

} } // namespace details // namespace odbc

#endif // ODBC_DETAILS_STATEMENT_VISITOR_HPP
